package com.cash.loan.modular.cash.controller;

import com.cash.loan.common.result.ServerResponse;
import com.cash.loan.modular.cash.AdNameEnum;
import com.cash.loan.modular.cash.service.AdService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author Administrator
 * @description
 * @date 2018年10月02 19:09
 */
@RestController
@RequestMapping(value = "/ad")
@Api(description = "广告展示接口")
public class AdController {

    @Autowired
    private AdService adService;

    @ApiOperation("开屏广告")
    @GetMapping(value = "/open")
    public ServerResponse openAd(@RequestHeader(value = "uitype",required = false,defaultValue = "0") Integer uiType) {
        Map<String,Object> result = adService.getAdInfoByType(AdNameEnum.OPEN.getName(),uiType);
        return ServerResponse.getSuccess("success",result);
    }

    @ApiOperation("插屏广告")
    @GetMapping(value = "/insert")
    public ServerResponse inertAd(@RequestHeader(value = "uitype",required = false,defaultValue = "0") Integer uiType) {
        Map<String,Object> result = adService.getAdInfoByType(AdNameEnum.INSERT.getName(),uiType);
        return ServerResponse.getSuccess("success",result);
    }

    @ApiOperation("浮屏广告")
    @GetMapping(value = "/float")
    public ServerResponse floatAd(@RequestHeader(value = "uitype",required = false,defaultValue = "0") Integer uiType) {
        Map<String,Object> result = adService.getAdInfoByType(AdNameEnum.FLOAT.getName(),uiType);
        return ServerResponse.getSuccess("success",result);
    }

}
